import 'dart:typed_data';

import 'package:dio/dio.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';

import '../utils/toast_util.dart';

class SAveX {
  ///存储图片
  static saveImage(String url, String fileName) async {
    var response = await Dio()
        .get(url, options: Options(responseType: ResponseType.bytes));
    final result = await ImageGallerySaver.saveImage(
        Uint8List.fromList(response.data),
        quality: 60,
        name: fileName);
    Map<Object?, Object?> saveJson = result;
    if (saveJson["isSuccess"] == true) {
      Toast.showToast("已保存到系统相册");
    } else {
      Toast.showToast("保存图片失败");
    }
    // saveJson.
  }

  ///存储文件
  static saveFile() async {}
}
